/**
 * login模块接口列表
 */

import base from '@/common/base'; // 导入接口域名列表
import axios from '@/common/http'; // 导入http中创建的axios实例
import qs from 'qs'; // 根据需求是否导入qs模块

const member = {

    /**
     * 获取用户账号信息
     */
    index() {
        return axios({
            method: 'get',
            url: `${base.sq}My/index`,
            headers:{'load':1}
        });
    },

    /**
     * 用户资料更新
     * @param params
     */
    update(params) {
        return axios({
            method: 'post',
            url: `${base.sq}Account/update`,
            data: qs.stringify(params)
        });
    },

    /**
     * 用户收藏
     * @param page 页数
     */
    getCollect(page=1) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getCollect`,
            params: {page: page}
        });
    },

    /**
     * 用户收藏车辆
     * @param page 页数
     */
    getCollectCar(page=1) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getCarList`,
            params: {page: page}
        });
    },

    /**
     * 用户收藏文章
     * @param page 页数
     */
    getCollectArt(page=1) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getArtList`,
            params: {page: page}
        });
    },

    /**
     * 我的发布
     * @param page 页数
     * @param status 0未售 1已售
     */
    getRelease(page, status) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getRelease`,
            params: {page: page, status: status},
        });
    },

    /**
     * 我的发布刷新
     */
    refreshCar(params) {
        return axios({
            method: 'post',
            url: `${base.sq}My/refreshUserCar`,
            data: qs.stringify(params)
        });
    },

    /**
     * 删除收藏车辆
     * @param params
     */
    delCollect(id) {
        return axios({
            method: 'post',
            url: `${base.sq}My/delCollect`,
            params: {id: id},
        });
    },

    /**
     * 删除收藏文章
     * @param params
     */
    delArticle(id) {
        return axios({
            method: 'post',
            url: `${base.sq}My/delArticle`,
            params: {id: id},
        });
    },

    delRelease(id) {
        return axios({
            method: 'post',
            url: `${base.sq}My/delRelease`,
            params: {id: id},
        });
    },
    toSold(id) {
        return axios({
            method: 'post',
            url: `${base.sq}My/toSold`,
            params: {id: id},
        });
    },
    getOrder(page, status) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getOrder`,
            params: {page: page, status: status},
        });
    },
    /**
     * 添加订阅
     * @param params
     */
    addBook(params) {
        return axios({
            method: 'post',
            url: `${base.sq}My/addBook`,
            data: qs.stringify(params)
        });
    },
    editBook(params) {
        return axios({
            method: 'post',
            url: `${base.sq}My/editBook`,
            data: qs.stringify(params),
        });
    },
    getBook(types=0) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getBook`,
            params: {types: types}
        });
    },
  /**
   * 删除订阅
   * @param params
   */
  delBook(params) {
      return axios({
        method: 'post',
        url: `${base.sq}My/delBook`,
        data: qs.stringify(params),
      });
    },
    getBookInfo(id,page=1) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getBookInfo`,
            params: {id: id,page:page},
        });
    },

    /**
     * 用户佣金交易记录
     */
    getRecord(page,type) {
        return axios({
            method: 'get',
            url: `${base.sq}My/getUserRecord`,
            params: {page: page,type:type},
        });
    },

    /**
     * 用户提现佣金
     */
    userRefund(params){
        return axios({
            method: 'post',
            url: `${base.sq}My/userRefund`,
            data: qs.stringify(params)
        });
    },
};

export default member;
